package com.chat.xx.utiles;

import com.alibaba.fastjson.JSONObject;
import com.chat.xx.beam.entity.UserEntity;
import com.chat.xx.beam.vo.WebSocketVo;

import java.lang.reflect.Field;

public class Tool {
    public static Boolean objProIsNull(Object obj) throws IllegalAccessException {
        Boolean bool = Boolean.FALSE;
        Field[] field = obj.getClass().getDeclaredFields();
        for(int j=0 ; j<field.length ; j++){ //遍历所有属性
            Field f = field[j];
            f.setAccessible(true);
            if(f.get(obj) == null || f.get(obj) == ""){
                bool = Boolean.TRUE;
                break;
            }
        }
        return bool;
    }
    public static <T> String wbSendMsg(String header,T body){
        WebSocketVo<T> webSocketVo = new WebSocketVo<>();
        webSocketVo.setHeader(header);
        webSocketVo.setBody(body);
        return JSONObject.toJSONString(webSocketVo);
    }
}
